<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
$vi_name = $_POST["vi_name"];
$en_name = $_POST["en_name"];
$link = $_POST["link"];



$sql = sprintf("insert into  tblresource (vi_name,en_name,link) values (%s,%s,%s)",
		GetSQLValueString($vi_name,"text"),
		GetSQLValueString($en_name,"text"),
		GetSQLValueString($link,"text"));
		
$rs = mysql_query($sql)or die(mysql_error());
if( $rs!=1){
	?>
				<script language="javascript">
					alert("Không thêm được tài nguyên cho bài viết!");
					window.location="rslist";
				</script>
				<?php
			}
			else
			{
				
				?>
				<script language="javascript">
				window.location="rslist";
				alert("Thêm tài nguyên thành công!");
				
				</script>
				<?php
			}

		

?>
	